package com.cal.utms.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.cal.utms.logAudit.AuditLogInt;
import com.cal.utms.util.ValueConvert;

/**
 * The persistent class for the user_group database table.
 * 
 */
@Entity
@Table(name = "user_group")
@NamedQuery(name = "UserGroup.findAll", query = "SELECT u FROM UserGroup u")
public class UserGroup implements Serializable, AuditLogInt {
	private static final long serialVersionUID = 1L;

	// ID, GROUP_NAME, GROUP_CODE, FUND_MANAGER
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID")
	private int id;

	@Column(name = "FUND_MANAGER")
	private byte fundManager;

	@Column(name = "GROUP_CODE")
	private String groupCode;

	@Column(name = "GROUP_NAME")
	private String groupName;

	// @OneToMany(fetch = FetchType.EAGER, mappedBy = "userGroup", cascade = {
	// CascadeType.ALL })
	// @Fetch(value = FetchMode.SUBSELECT)
	// private List<UserGroupScreen> userGroupScreens;

	public UserGroup() {
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public byte getFundManager() {
		return this.fundManager;
	}

	public void setFundManager(byte fundManager) {
		this.fundManager = fundManager;
	}

	public String getGroupCode() {
		return this.groupCode;
	}

	public void setGroupCode(String groupCode) {
		this.groupCode = groupCode;
	}

	public String getGroupName() {
		return this.groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	// public List<UserGroupScreen> getUserGroupScreens() {
	// return this.userGroupScreens;
	// }
	//
	// public void setUserGroupScreens(List<UserGroupScreen> userGroupScreens) {
	// this.userGroupScreens = userGroupScreens;
	// }
	//
	// public UserGroupScreen addUserGroupScreen(UserGroupScreen
	// userGroupScreen) {
	// getUserGroupScreens().add(userGroupScreen);
	// userGroupScreen.setUserGroup(this);
	//
	// return userGroupScreen;
	// }
	//
	// public UserGroupScreen removeUserGroupScreen(UserGroupScreen
	// userGroupScreen) {
	// getUserGroupScreens().remove(userGroupScreen);
	// userGroupScreen.setUserGroup(null);
	//
	// return userGroupScreen;
	// }

	@Transient
	@Override
	public Long getLogId() {
		return ValueConvert.toLong(this.id);
	}

	@Transient
	@Override
	public String getLogDeatil() {
		StringBuilder sb = new StringBuilder();
		sb.append("User Group Id : ").append(id).append(" Group code : ").append(this.groupCode);

		return sb.toString();
	}
}